export function generateColor(courseName) {
  // 计算课程名称的哈希码
  let hashCode = 0;
  for (let i = 0; i < courseName.length; i++) {
    hashCode = courseName.charCodeAt(i) + ((hashCode << 5) - hashCode);
  }

  // 将哈希码转换为十六进制颜色代码并加上前缀 '#'
  let color = (hashCode & 0x00ffffff).toString(16);
  color = "#" + ("00000" + color).slice(-6);

  // 将颜色稍微变浅一点，可以根据需要进行微调
  // const lightness = 0.7; // 浅度因子，范围为0到1
  // let rgb = parseInt(color.replace("#", ""), 16);
  // let r = (rgb >> 16) & 0xff;
  // let g = (rgb >> 8) & 0xff;
  // let b = rgb & 0xff;
  // r += Math.floor((255 - r) * lightness);
  // g += Math.floor((255 - g) * lightness);
  // b += Math.floor((255 - b) * lightness);
  // color = `#${((r << 16) | (g << 8) | b).toString(16)}`;

  return color;
}
